﻿using Smartstore.Core.Content.Menus;
using Smartstore.Web.Rendering.Menus;

namespace Smartstore.Web.Components
{
    public class HomeBannersViewComponent : SmartViewComponent
    {
        private readonly IMenuService _menuService;

        public HomeBannersViewComponent(
            IMenuService menuService)
        {
            _menuService = menuService;
        }

        public async Task<IViewComponentResult> InvokeAsync()
        {
            var menu = await _menuService.GetMenuAsync("Main");

            if (menu == null)
            {
                return Empty();
            }

            var model = await menu.CreateModelAsync("Main", ViewContext);

            return View(model);
        }
    }
}
